home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROGS.ZIP / STRPSGML.ICN < prev    next >
Text File  |  1992-11-26  |  3KB  |  83 lines

  1. ############################################################################
  2. #
  3. #    File:     strpsgml.icn
  4. #
  5. #    Subject:  Program to strip/translate SGML tags
  6. #
  7. #    Author:   Richard L. Goerwitz
  8. #
  9. #    Date:     June 3, 1991
  10. #
  11. ###########################################################################
  12. #
  13. #    Version:  1.9
  14. #
  15. ###########################################################################
  16. #
  17. #  Strip or perform simple translation on SGML <>-style tags.  Usage
  18. #  is as follows:
  19. #
  20. #      strpsgml [-f translation-file] [left-delimiter [right-delimiter]]
  21. #
  22. #  The default left-delimiter is <, the default right delimiter is >.
  23. #  If no translation file is specified, the program acts as a strip-
  24. #  per, simply removing material between the delimiters.  Strpsgml
  25. #  takes its input from stdin, writing to stdout.
  26. #
  27. #  The format of the translation file is:
  28. #
  29. #      code    initialization    completion
  30. #
  31. #  A tab or colon separates the fields.  If you want to use a tab or colon
  32. #  as part of the text (and not as a separator), place a backslash before
  33. #  it.  The completion field is optional.  There is not currently any way
  34. #  of specifying a completion field without an initialization field.  Do
  35. #  not specify delimiters as part of code.
  36. #
  37. #  Note that, if you are translating SGML code into font change or escape
  38. #  sequences, you may get unexpected results.  This isn't strpsgml's
  39. #  fault.  It's just a matter of how your terminal or WP operate.  Some
  40. #  need to be "reminded" at the beginning of each line what mode or font
  41. #  is being used.  Note also that stripsgml assumes < and > as delimiters.
  42. #  If you want to put a greater-than or less-than sign into your text,
  43. #  put a backslash before it.  This will effectively "escape" the spe-
  44. #  cial meaning of those symbols.  It is now possible to change the
  45. #  default delimiters, but the option has not been thoroughly tested.
  46. #
  47. ############################################################################
  48. #
  49. #  Links: slashbal, stripunb, readtbl
  50. #
  51. ############################################################################
  52.  
  53. link slashbal, stripunb, readtbl
  54.  
  55. procedure main(a)
  56.  
  57.     local usage, _arg, L, R, map_file, t, readtbl, line, stripunb, last_k
  58.  
  59.     usage:=
  60.      "usage:  stripsgml [-f map-file] [left-delimiter(s) [right-delimiter(s)]]"
  61.  
  62.     L := '<'; R := '>'
  63.     while _arg := get(a) do {
  64.         if _arg == "-f" then {
  65.             map_file := open(get(a)) |
  66.                 stop("stripsgml:  can't open map_file\n",usage)
  67.             t := readtbl(map_file)
  68.         }
  69.         else {
  70.             L := _arg
  71.             R := cset(get(a))
  72.         }
  73.     }
  74.  
  75.     every line := !&input do
  76.     write(stripunb(L,R,line,&null,&null,t))  # t is the map table
  77.  
  78.     # last_k is the stack used in stripunb.icn
  79.     if *\last_k ~= 0 then
  80.     stop("Unexpected EOF encountered.  Expecting ", pop(last_k), ".")
  81.  
  82. end
  83.